home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 120 / CD Gamer Issue 120 (March 2003) (Disc 2).ISO / mods / Q2_Codered / codeRED1_0.exe / Data1.cab / NPC_surgeon.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-07  |  3.6 KB  |  147 lines

  1. /*
  2. ==============================================================================
  3.  
  4. NPC_Surgeon - yup, an alien surgeon.
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. #include "g_local.h"
  10. #include "npc_surgeon.h"
  11.  
  12. static int sound_talk1;
  13. static int sound_talk2;
  14. static int sound_operate;
  15. static int sound_die;
  16.  
  17. void npc_surgeon_operate (edict_t *self);
  18.  
  19. void surgeon_talk(edict_t *self)
  20. {
  21.     if(random() < 0.5)
  22.         gi.sound (self, CHAN_VOICE, sound_talk1, 1 , ATTN_NORM, 0);
  23.     else
  24.         gi.sound (self, CHAN_VOICE, sound_talk2, 1, ATTN_NORM, 0);
  25. }
  26.  
  27. void surgeon_operate_noise(edict_t *self)
  28. {
  29.     gi.sound (self, CHAN_VOICE, sound_operate, 1, ATTN_NORM, 0);
  30. }
  31.  
  32. mframe_t npc_surgeon_frames_examine[] =
  33. {
  34.     ai_move, 0, NULL,
  35.     ai_move, 0, NULL,
  36.     ai_move, 0, NULL,
  37.     ai_move, 0, NULL,
  38.     ai_move, 0, NULL,
  39.     ai_move, 0, NULL,
  40.     ai_move, 0, NULL,
  41.     ai_move, 0, NULL,
  42.     ai_move, 0, NULL,
  43.     ai_move, 0, NULL,
  44.     ai_move, 0, surgeon_talk,
  45.     ai_move, 0, NULL,
  46.     ai_move, 0, NULL,
  47.     ai_move, 0, NULL,
  48.     ai_move, 0, NULL
  49.     
  50. };
  51. mmove_t npc_surgeon_move_examine = {FRAME_examine01, FRAME_examine15, npc_surgeon_frames_examine, npc_surgeon_operate};
  52.  
  53. void npc_surgeon_examine (edict_t *self)
  54. {
  55.     if (random() < 0.2)
  56.         self->monsterinfo.currentmove = &npc_surgeon_move_examine;
  57. }
  58.  
  59. mframe_t npc_surgeon_frames_operate[] =
  60. {
  61.     ai_move, 0, npc_surgeon_examine,
  62.     ai_move, 0, NULL,
  63.     ai_move, 0, NULL,
  64.     ai_move, 0, NULL,
  65.     ai_move, 0, surgeon_operate_noise,
  66.     ai_move, 0, NULL,
  67.     ai_move, 0, NULL,
  68.     ai_move, 0, NULL,
  69.     ai_move, 0, NULL,
  70.     ai_move, 0, NULL,
  71.     ai_move, 0, NULL,
  72.     ai_move, 0, NULL,
  73.     ai_move, 0, NULL,
  74.     ai_move, 0, NULL,
  75.     ai_move, 0, NULL
  76.     
  77. };
  78. mmove_t npc_surgeon_move_operate = {FRAME_operate01, FRAME_operate15, npc_surgeon_frames_operate, NULL};
  79.  
  80. void npc_surgeon_operate (edict_t *self)
  81. {
  82.     self->monsterinfo.currentmove = &npc_surgeon_move_operate;
  83. }
  84.  
  85. void surgeon_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  86. {
  87.     int        n;
  88.     
  89.     gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
  90.  
  91.     for (n = 0; n < 4; n++)
  92.     {
  93.         ThrowGib (self, "models/objects/gibs/mart_gut/tris.md2", damage, GIB_ORGANIC, EF_GREENGIB);
  94.         ThrowHead (self, "models/objects/gibs/mart_head/tris.md2", damage, GIB_ORGANIC, EF_GREENGIB);
  95.     }
  96.  
  97.     self->deadflag = DEAD_DEAD;
  98. }
  99.  
  100. void SP_npc_surgeon (edict_t *self)
  101. {
  102.     if (deathmatch->value)
  103.     {
  104.         G_FreeEdict (self);
  105.         return;
  106.     }
  107.  
  108.     // pre-caches
  109.  
  110.     sound_talk1 = gi.soundindex ("martian/ack2.wav");
  111.     sound_talk2 = gi.soundindex ("martian/ack3.wav");
  112.      sound_operate = gi.soundindex ("martian/operate.wav");
  113.     sound_die = gi.soundindex("martian/death.wav");
  114.         
  115.     self->s.modelindex = gi.modelindex("models/npc/martian_surgeon/tris.md2");
  116.     
  117.     VectorSet (self->mins, -8, -8, -26);
  118.     VectorSet (self->maxs, 8, 8, 48);    // small so he can get up to the table
  119.     self->movetype = MOVETYPE_STEP;
  120.     self->solid = SOLID_BBOX;
  121.     self->s.skinnum = 0;
  122.  
  123.     self->max_health = 150;
  124.     self->health = self->max_health;
  125.     self->gib_health = 0;
  126.     self->mass = 100;
  127.  
  128.     self->pain = NULL;
  129.     self->die = surgeon_die;
  130.  
  131.     self->monsterinfo.stand = npc_surgeon_operate;
  132.     self->monsterinfo.walk = npc_surgeon_operate;
  133.     self->monsterinfo.run = npc_surgeon_operate;
  134.     self->monsterinfo.dodge = NULL;
  135.     self->monsterinfo.attack = NULL;
  136.     self->monsterinfo.melee = NULL;
  137.     self->monsterinfo.sight = NULL;
  138.     self->monsterinfo.search = NULL;
  139.  
  140.     self->monsterinfo.currentmove = &npc_surgeon_move_operate;
  141.     self->monsterinfo.scale = MODEL_SCALE;
  142.  
  143.     gi.linkentity (self);
  144.  
  145.     walkmonster_start (self);
  146. }
  147.